import webComponent from '@/views/main-components/web.vue';
let extend = { vue: null, modal: { ele: null, url: null } };

let vue;

extend.init = (vue) => {
    let sy = window.sy;
    extend.vue = vue;
    sy.modalDialog = function(info, width, height) {
        let config = {
            title: info.title,
            url: info.url,
            width: width,
        }


        if (info.buttons) {
            info.buttons.forEach((btn) => {
                if (btn.id == "eovaSave") {
                    config.onOk = btn.handler;
                    config.okText = btn.text.replace(/\&nbsp;/g, '');
                } else if (btn.id == "eovaCancel") {
                    config.cancelText = btn.text.replace(/\&nbsp;/g, '');
                    config.onCancel = btn.handler;
                } else if (btn.id == "find_ok") {
                    config.onOk = btn.handler;
                    config.okText = btn.text.replace(/\&nbsp;/g, '');
                } else if (btn.id == "find_clear") {
                    config.cancelText = btn.text.replace(/\&nbsp;/g, '');
                    config.onCancel = btn.handler;
                }
            });

            if(info.buttons.length==1){
                config.onOk = info.buttons[0].handler;
                config.okText = info.buttons[0].text.replace(/\&nbsp;/g, '');
            }

        }
        let $dialog;
        if (info.id == "eova_find_dialog") {
            extend.vue.$store.commit('showFindModal', config);
            $dialog = $(extend.vue.$store.state.app.findModal.ele);
        } else {
            extend.vue.$store.commit('showModal', config);
            $dialog = $(extend.vue.$store.state.app.modal.ele);
        }
        $dialog.dialog = (...args) => {};
        return $dialog;

    }



}

export default extend;